package com.roadmap.client.module.life;

import java.util.List;

import com.roadmap.client.module.BaseManager;
import com.roadmap.common.BaseEntity;
import com.roadmap.entities.Achievement;
import com.roadmap.entities.Aspirant;
import com.roadmap.exception.InvalidQueryException;
import com.roadmap.exception.InvalidValueException;
import com.roadmap.exception.NullObjectException;
import com.roadmap.exception.ServerException;

public class AchievementManager extends BaseManager {

	public AchievementManager(String aspirantId, Aspirant parent) {
		super(aspirantId, Achievement.class, parent);
	}

	public AchievementManager(String aspirantId) {
		super(aspirantId, Achievement.class);
	}

	@Override
	public List<BaseEntity> getEntitiesOfParent() throws NullObjectException,
			InvalidQueryException, ServerException, InvalidValueException {
		StringBuffer hsql = new StringBuffer(getParentIdName());
		hsql.append("='");
		hsql.append(getParent().getId());
		hsql.append("' order by happenDate DESC");
		return (List<BaseEntity>) getDbUtil().getEntitiesByCriteria(
				getManagedEntityType(), hsql.toString());
	}

}
